//
//  RNOLMeHeader.m
//  RongNiuOnline
//
//  Created by apple on 2018/4/20.
//  Copyright © 2018年 rongniu. All rights reserved.
//

#import "RNOLMeHeader.h"
#import "RNOLMeCardView.h"
#import "RNOLHomeIndexView.h"

@interface RNOLMeHeader ()

@property (nonatomic,strong)  RNOLMeCardView *cardView ;

@end

@implementation RNOLMeHeader

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = KWhiteColor;
        [self addHeaderSubViews];
    }
    return self;
}

- (void)addHeaderSubViews{    
    RNOLMeCardView *cardView = [RNOLMeCardView FromXIB];
     cardView.frame = CGRectMake(25, 10, KWIDTH - 50 , 200);
    [self addSubview: cardView];
		self.cardView = cardView;
	
	@weakify(self);
	[cardView setRechargeBlock:^{
		@strongify(self);
		!self.rechargeBlock? : self.rechargeBlock();
	}];
	[cardView setWithdrawBlock:^{
		@strongify(self);
		!self.withdrawBlock? : self.withdrawBlock();
	}];
    
    NSArray *titles =  @[@"我的投资",@"回款日历",@"银行卡",@"资金明细"];
    NSArray *images = @[@"rnol_me_touzi",@"rnol_me_certificate",@"rnol_me_bankcard",@"rnol_me_moneydetail"];
     RNOLHomeIndexView *indexView = [[RNOLHomeIndexView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(cardView.frame)+15, KWIDTH , 80) Titles:titles images:images callBack:^(NSInteger index) {
         !self.indexBlock? : self.indexBlock(index);
         NSLog(@"%@",titles[index]);
     }];
    [self addSubview: indexView];
    
    UIView *bottomLineView = [RNOLUnitTool createViewWithBackgroundColor: kBgColor];
    bottomLineView.frame = CGRectMake(0, CGRectGetMaxY(indexView.frame), KWIDTH , 5);
	[self addSubview: bottomLineView];
}

@end

